//
//  StatusCellBottomView.swift
//  SinaWeibo
//
//  Created by liyue on 15/11/15.
//  Copyright © 2015年 李越. All rights reserved.
//

import UIKit

class StatusCellBottomView: UIView {

    
    @objc private func retweetedBtnDidClick() {
        
        let temp = TempViewController()
        retweetedBtn.NavController()?.pushViewController(temp, animated: true)
    }
    
    override init(frame: CGRect) {
        
        super.init(frame: frame)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupUI() {
        
        //添加子视图
        addSubview(retweetedBtn)
        addSubview(composeBtn)
        addSubview(likeBtn)
        
        let w: CGFloat = 0.4
        //约束
        retweetedBtn.snp_makeConstraints { (make) -> Void in
            
            make.top.equalTo(snp_top)
            make.left.equalTo(snp_left)
            make.height.equalTo(snp_height)
        }
        
        let setView1 = setView()
        addSubview(setView1)
        setView1.snp_makeConstraints { (make) -> Void in
            
            make.left.equalTo(retweetedBtn.snp_right)
            make.height.equalTo(retweetedBtn.snp_height).multipliedBy(w)
            make.centerY.equalTo(self.snp_centerY)
            make.width.equalTo(w)
        }
        
        composeBtn.snp_makeConstraints { (make) -> Void in
            
            make.left.equalTo(retweetedBtn.snp_right)
            make.top.equalTo(snp_top)
            make.height.equalTo(snp_height)
            make.width.equalTo(retweetedBtn.snp_width)
        }
        
        let setView2 = setView()
        addSubview(setView2)
        setView2.snp_makeConstraints { (make) -> Void in
            
            make.left.equalTo(composeBtn.snp_right)
            make.height.equalTo(composeBtn.snp_height).multipliedBy(w)
            make.centerY.equalTo(self.snp_centerY)
            make.width.equalTo(w)
        }
        
        likeBtn.snp_makeConstraints { (make) -> Void in
            
            make.left.equalTo(composeBtn.snp_right)
            make.top.equalTo(snp_top)
            make.right.equalTo(snp_right)
            make.height.equalTo(snp_height)
            make.width.equalTo(composeBtn.snp_width)
        }
        
        retweetedBtn.addTarget(self, action: "retweetedBtnDidClick", forControlEvents: .TouchUpInside)
    }
    
    //创建分割线
    private func setView() -> UIView {
        
        let v = UIView()
        v.backgroundColor = UIColor.darkGrayColor()
        return v
    }
    
    private lazy var retweetedBtn: UIButton = UIButton(title: "转发", backImage: nil, color: UIColor.darkGrayColor(), image: "timeline_icon_retweet", size: 10)
    private lazy var composeBtn: UIButton = UIButton(title: "评论", backImage: nil, color: UIColor.darkGrayColor(), image: "timeline_icon_comment", size: 10)
    private lazy var likeBtn: UIButton = UIButton(title: "赞", backImage: nil, color: UIColor.darkGrayColor(), image: "timeline_icon_unlike", size: 10)

}
